package com.sicpa.web.controller.system;

import com.sicpa.common.core.controller.BaseController;
import com.sicpa.common.core.domain.AjaxResult;
import com.sicpa.common.core.page.TableDataInfo;
import com.sicpa.system.service.IAssuranceBusinessReportFormService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

/**
 * @ClassName:报表接口
 * @author: zf
 * @description: 报表接口controller层
 * @date 2020/9/16
 */
@Api(value = "报表接口")
@RestController
@RequestMapping("/business/reportForm")
public class AssuranceBusinessReportFormController extends BaseController {
    private IAssuranceBusinessReportFormService iAssuranceBusinessReportFormService;

    @Autowired
    public AssuranceBusinessReportFormController(IAssuranceBusinessReportFormService iAssuranceBusinessReportFormService){
        this.iAssuranceBusinessReportFormService = iAssuranceBusinessReportFormService;
    }

    /**
     * 获取报表 表格数据
     * @param query 查询条件 type 报表的类型
     * @return
     */
    @ApiOperation("获取报表 表格数据")
    @GetMapping("/getTableColumn")
    public TableDataInfo getAssureanceReportFormData(@RequestParam HashMap<String,Object> query){
        return iAssuranceBusinessReportFormService.getAssureanceReportFormData(query);
    }

    /**
     * 获取报表 表格的表头
     * @param query 查询条件 type 报表的类型
     * @return
     */
    @ApiOperation(" 获取报表 表格的表头")
    @GetMapping("/getTableHeader")
    public AjaxResult getAssureanceReportFormTabel(@RequestParam HashMap<String,Object> query) throws IOException {
        HashMap<String, Object> result =  iAssuranceBusinessReportFormService.getAssureanceReportFormTabel( query);
        return AjaxResult.success(result);
    }

    /**
     * 下载报表
     * @param query 查询条件 type 报表的类型
     * @return
     */
    @ApiOperation(" 下载报表")
    @GetMapping("/downloadReportForm")
    public AjaxResult downloadReportForm(@RequestParam HashMap<String,Object> query) throws Exception{
        return iAssuranceBusinessReportFormService.downloadReportForm(query);
    }
}
